<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="e" uri="/easytogo-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
	<e:base/>
	<script type="text/javascript">
		function newUser(){
			var url="${pageContext.request.contextPath}/admin/user_toNew.action";
			$("#newFrame").attr("src",url);
		}
		function updateUser(id){
			var url="${pageContext.request.contextPath}/admin/user_toUpdate.action?id="+id;
			$("#newFrame").attr("src",url);
		}
		function deleteUser(id){
			confirmInfo('删除确认', '您确定删除此用户?', function(r){
            	if(r){
            		var url="${pageContext.request.contextPath}/admin/user_delete.action";
					$.ajax({
						type: "post",
						url: url,
						data: {"id":id},
						dataType:"text",
						success: function(msg){
							if(msg=="failed"){
								alert("删除失败!");
							}else{
								if("${successAlert}"=="1"){
									alert("删除成功!");
								}
							}
							location.reload();
						}
					}); 
            	}
            });   
		}
		function afterSave(){
			$("#newFrame").attr("src","");
			location.reload();
		}
    </script>
  </head>
  
  <body style="overflow: hidden;">
	  <a href="javascript:newUser();">新增</a>
	  <div style="height: 100%;width: 40%;float: left;overflow: auto;">
		  <table border="1">
		  	<tr><th>用户类型</th><th>用户名称</th><th>真实名称</th><th>注册时间</th><th colspan="2">操作</th></tr>
			  <s:iterator value="userList" var="r">
			  	<tr><td><s:if test="admin==1">后台</s:if><s:else>前台</s:else></td><td>${username}&nbsp;</td><td>${realname}&nbsp;</td><td>${registDate}&nbsp;</td><td><a href="javascript:updateUser('${id}');">修改</a></td><td><a href="javascript:deleteUser('${id}');">删除</a></td></tr>
			  </s:iterator>
		  </table>
	  </div>
	  <div id="contextDiv" style="height: 100%;width: 60%;float: left;">
	  	<iframe id="newFrame" src="" width="90%" height="90%" frameborder="0"></iframe>
	  </div>
  </body>
</html>
